package com.netrust.cmsx.entity.module.site;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.netrust.cmsx.entity.module.sys.Attach;


/**
 * @title
 * @description 留言实体类
 * @author ZYC
 * @version v_1.0.0
 * @date 2017年6月30日 上午10:18:43
 */
@Entity
@Table(name = "t_leave_message")
public class LeaveMessage implements Serializable {

	private static final long serialVersionUID = -7093656339259186450L;

	// 留言类型
	public static final String ADVISE = "advise";
	public static final String COMMENT = "comment";
	public static final String OTHER = "other";

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "lm_id", columnDefinition = "int(11)", nullable = false, unique = true)
	private Integer id;// 主键

	@Column(name = "lm_title", columnDefinition = "varchar(100)")
	private String title;// 标题

	@Column(name = "lm_content", columnDefinition = "varchar(255)")
	private String content;// 留言内容

	@Column(name = "lm_type", columnDefinition = "varchar(20)")
	private String type;// 留言种类

	@Column(name = "lm_man", columnDefinition = "varchar(50)")
	private String man;// 留言人姓名

	@Column(name = "lm_phone", columnDefinition = "varchar(50)")
	private String phone;// 留言人电话

	@Column(name = "lm_ip", columnDefinition = "varchar(15)")
	private String ip;// 留言人IP地址

	@Column(name = "lm_time", columnDefinition = "timestamp")
	private Timestamp time;// 留言时间

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "t_attach_leave_messages", joinColumns = @JoinColumn(name = "lm_id"), inverseJoinColumns = @JoinColumn(name = "a_id"))
	private Set<Attach> attachs = new HashSet<Attach>();

	public LeaveMessage() {
		super();
	}

	public LeaveMessage(Integer id, String title, String content, String type, String man, String phone, String ip,
			Timestamp time) {
		super();
		this.id = id;
		this.title = title;
		this.content = content;
		this.type = type;
		this.man = man;
		this.phone = phone;
		this.ip = ip;
		this.time = time;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getMan() {
		return man;
	}

	public void setMan(String man) {
		this.man = man;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Timestamp getTime() {
		return time;
	}

	public void setTime(Timestamp time) {
		this.time = time;
	}

	public Set<Attach> getAttachs() {
		return attachs;
	}

	public void setAttachs(Set<Attach> attachs) {
		this.attachs = attachs;
	}

	@Override
	public String toString() {
		return "LeaveMessage [id=" + id + ", title=" + title + ", content=" + content + ", type=" + type + ", man="
				+ man + ", phone=" + phone + ", ip=" + ip + ", time=" + time + "]";
	}

}
